package com.cjk.console.ctrl;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cjk.console.SessionApi;
import com.cjk.console.request.StbLogRequest;
import com.cjk.console.service.LogService;
import com.cjk.foundation.commons.response.PageResponse;
import com.cjk.foundation.commons.response.Response;

@Controller
@RequestMapping("/log")
public class LogController {
	
	@Autowired
	private LogService logService;
	
	/**
	 * 当前各个频道播放数
	 * @param request
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/getCurrentChannelPlayNum.do", method = RequestMethod.POST)
	public Response getCurrentChannelPlayNum(@RequestBody StbLogRequest request, HttpSession session) {
		final Integer userId = SessionApi.getLoginUserId(session);
		return logService.getCurrentChannelPlayNum(request, userId);
	}
	
	/**
	 * 设备详情系统信息
	 * @param sn
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/getCurrentSysInfoLog.do", method = RequestMethod.POST)
	public Response getCurrentSysInfoLog(String sn) {
		return logService.getCurrentSysInfoLog(sn);
	}
	
	/**
	 * 设备详情流量日志
	 * @param sn
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/getFlowLog.do", method = RequestMethod.POST)
	public Response getFlowLog(String sn) {
		return logService.getFlowLog(sn);
	}
	
	/**
	 * 在线租户
	 * @param request
	 * @param session
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/getCurrentTenants.do", method = RequestMethod.POST)
	public PageResponse getCurrentTenants(@RequestBody StbLogRequest request, HttpSession session) {
		final Integer userId = SessionApi.getLoginUserId(session);
		return logService.getWatchLogList(request, userId);
	}
	
}
